package top.lcm889.oj.leetcodeTop200;

/**
 * @author Coder-lcm
 * @date 2021/4/6
 */
public class LC287_寻找重复数 {
    public int findDuplicate(int[] nums) {
        int len = nums.length;
        byte[] exist = new byte[len];
        for (int i = 0; i < len; i++) {
            if (exist[nums[i]] == 1) {
                return nums[i];
            }
            exist[nums[i]] = 1;
        }
        return -1;
    }

    public static void main(String[] args) {
        LC287_寻找重复数 test = new LC287_寻找重复数();
        System.out.println(test.findDuplicate(new int[]{1,1}));
    }
}
